﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LINQ = JLL.China.Infrastructure.Repositories.LINQ2SQL;
using JLL.China.Infrastructure.Repositories.ProjectDirectory;
using JLL.China.Model;
namespace JLL.China.Infrastructure.Repositories.ProjectDirectory
{
    public class ProjectDirectoryFactory
    {
        public static Model.ProjectDirectory FromLINQObject(LINQ.ProjectDirectory listing)
        {
            if (listing == null)
            {
                return null;
            }
            else
            {
                var model = new Model.ProjectDirectory
                {
                    ID = Int32.Parse(listing.Listing_ID.ToString()),
                    ProjectNameFID = listing.ProjectNameFID,
                    PropertyClsssm  = listing.PropertyClsssm,
                    StreetNameFID = listing.StreetNameFID,
                    PropertyTypeFID = listing.PropertyTypeFID,
                    CountryFID = listing.CountryFID,
                    CityFID = listing.CityFID,
                    LocaltionFID = listing.LocaltionFID,
                    SubAreaFID = listing.SubAreaFID,
                    Tenure = listing.Tenure,
                    StatusFID = listing.StatusFID,
                    Longitude = listing.Longitude,
                    Latitude = listing.Latitude,
                    CreateDate = listing.CreateDate,
                    ListingDate = listing.ListingDate,
                    ListingExpiry = listing.ListingExpiry,
                    CreateBy = listing.CreateBy,
                    UpdateBy = listing.UpdateBy,
                    UpdateDate = listing.UpdateDate,
                    HouseNumber = listing.HouseNumber
                    
                };
                return model;
            }
        }

        public static LINQ.ProjectDirectory ToLINQObject(Model.ProjectDirectory listing)
        {
            var model = new LINQ.ProjectDirectory{
                Listing_ID = listing.ID,
                ProjectNameFID = listing.ProjectNameFID,
                PropertyClsssm = listing.PropertyClsssm,
                StreetNameFID = listing.StreetNameFID,
                PropertyTypeFID = listing.PropertyTypeFID,
                CountryFID = listing.CountryFID,
                CityFID = listing.CityFID,
                LocaltionFID = listing.LocaltionFID,
                SubAreaFID = listing.SubAreaFID,
                Tenure = listing.Tenure,
                StatusFID = listing.StatusFID,
                Longitude = listing.Longitude,
                Latitude = listing.Latitude,
                CreateDate = listing.CreateDate,
                ListingDate = listing.ListingDate,
                ListingExpiry = listing.ListingExpiry,
                CreateBy = listing.CreateBy,
                UpdateBy = listing.UpdateBy,
                UpdateDate = listing.UpdateDate,
                HouseNumber = listing.HouseNumber
            };
            return model;
        }
    }
    
}
